package com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.action;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.bo.IWenTypeBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.SubTypeInfo;
import com.tjsinfo.tjsoa.system.bo.ILianDongBO;
import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.LianDong;
import com.tjsinfo.tjsoa.system.vo.User;


public class NiGaoFromFFAction extends Action{
	private ISystemUserBo systemUserBo;
	private ILianDongBO lianDongBO;
	private IWenTypeBO wenTypeBO;
	
	public IWenTypeBO getWenTypeBO() {
		return wenTypeBO;
	}

	public void setWenTypeBO(IWenTypeBO wenTypeBO) {
		this.wenTypeBO = wenTypeBO;
	}

	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}

	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}
	public ILianDongBO getLianDongBO() {
		return lianDongBO;
	}
	public void setLianDongBO(ILianDongBO lianDongBO) {
		this.lianDongBO = lianDongBO;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String rodomerstr = ToolKit.getRodomer();  //获得当前年月日十分秒 yyyyMMddkkmmssSS
		User user = SessionUser.getUser(request);
		
		
		try { 
			 String path =  super.getServlet().getServletContext().getRealPath("/");
			  FileInputStream   fis   =   new   FileInputStream(path+"documentationflow\\xingzhengfawen\\docs\\" +"temp.doc");   
		          FileOutputStream   fos   =   new   FileOutputStream(path+"documentationflow\\xingzhengfawen\\docs\\" + rodomerstr+".doc");   
		          byte[]   buf   =   new   byte[1024];   
		          int   i   =   0;   
		          while   (   (i   =   fis.read(buf))   !=   -1)   {   
		              fos.write(buf,   0,   i);   
		          }   
		          fis.close();   
		          fos.close();
		     }  
		     catch  (Exception  e)  {  
		           
		         e.printStackTrace();  
		     }
		request.setAttribute("rodomerstr", rodomerstr); 
		String state = request.getParameter("state");
		request.setAttribute("state", state); 
		List<LianDong> zhuSonglist =  lianDongBO.selectAllLianDong();
		request.setAttribute("zhusong", zhuSonglist);
		List<SubTypeInfo> subTypeList = wenTypeBO.selectSubType(1); //查询所有行政发文的文种
		request.setAttribute("subtypelist", subTypeList);

		return mapping.findForward("ok");
				
	}
	
}
